package com.shopping.mall.core.module.order.listener;


import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSON;
import com.shopping.mall.core.module.order.entity.Delivery;
import lombok.Data;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class DeliveryListener extends AnalysisEventListener<Delivery> {

    private static final Logger LOGGER = LoggerFactory.getLogger(DeliveryListener.class);

    /**
     * 每隔5条存储数据库，实际使用中可以3000条，然后清理list ，方便内存回收
     */
    private static final int BATCH_COUNT = 5;
    List<Delivery> list = new ArrayList<Delivery>();

    /**
     * 这个每一条数据解析都会来调用
     */
    @Override
    public void invoke(Delivery delivery, AnalysisContext context) {
        list.add(delivery);
    }

    /**
     * 所有数据解析完成了 都会来调用
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        LOGGER.info("所有数据解析完成！");
    }

}